<template>
	<!-- 商家底部导航栏 -->
	<view class="tabbar-main">
		<u-tabbar :value="tabbarValue" :placeholder="false" :border="false" @change="(name) => tabbarChange(name)" :fixed="true" :safeAreaInsetBottom="true">
			<u-tabbar-item :text="item.text" :icon="item.icon" @click="gotoPath(item.path)" v-for="(item, index) in tabbarList" :key="index"></u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
export default {
	name: 'hwxcStoreTabbar',
	data() {
		return {
			tabbarValue: 0,
			storeType: '',
			tabbarList:[
				{
					text:"工作台",
					icon:"grid",
					path:"/pages/storeSide/storeHome/storeHome"
				},
				{
					text:"订单管理",
					icon:"order",
					path:"/pages/storeSide/orderManagement/orderManagement"
				},
				{
					text:"我的",
					icon:"account",
					path:"/pages/storeSide/storeUser/storeUser"
				}
			],
			storeInfo: {},
			userInfo:{},
		};
	},

	async mounted() {
		this.storeType = this.$store.state.storeType;
		this.storeInfo = this.$store.state.storeInfo || {};
		this.userInfo = this.$store.state.userInfo || {};

		if(this.storeType == '1'){
			if(this.userInfo.user_id == this.storeInfo.user_id){
				this.tabbarList = [
					{
						text:"工作台",
						icon:"grid",
						path:"/pages/storeSide/storeHome/storeHome"
					},
					{
						text:"订单管理",
						icon:"order",
						path:"/pages/storeSide/orderManagement/orderManagement"
					},
					{
						text:"店员管理",
						icon:"server-man",
						path:"/pages/storeSide/clerkManage/clerkManage"
					},
					{
						text:"我的",
						icon:"account",
						path:"/pages/storeSide/storeUser/storeUser"
					}
				]
			}
		}

		this.tabbarValue = (await uni.getStorageSync('storeTabbarVal')) || 0;
	},

	methods: {
		gotoPath(path) {
			uni.reLaunch({
				url: path
			});
		},

		tabbarChange(name) {
			this.tabbarValue = name;
			uni.setStorageSync('storeTabbarVal', this.tabbarValue);
		}
	}
};
</script>

<style scoped lang="scss"></style>
